/**
 * 
 */
package com.wbl.server;

import java.util.List;

import com.zyy.java.Compare;
import com.zyy.java.CreatPlayers;
import com.zyy.java.CreatPoker;
import com.zyy.java.Dealer;
import com.zyy.java.Player;
import com.zyy.java.SendPoker;
import com.zyy.java.Shuffle;
import com.zyy.java.View;

/**
 * @Description:  
 * @version: v1.0.0
 * @author: wbl
 * @date: 2020年1月13日 下午3:41:04
 */
public class NiuInit {
	private static CreatPlayers cplayers;
	private static CreatPoker cpoker;
	private static Shuffle shuffle;
	private static SendPoker spoker; // 发牌
	private static View view;
	private static Player dealer; // 庄家
	private static List washedCards; // 洗过的牌
	private static Player[] players0; // 建好的玩家
	private static Player[] players1; // 发好牌的玩家
 
	public static String init() {
		String result= "";
		cpoker = new CreatPoker(); // 牌已经建好
		List cardsAll = cpoker.getCardsAll(); // 一、获取建好的牌
		int flag = 0;
		for (Object obj : cardsAll) {
			if (flag++ % 13 == 0) {
				System.out.println();
			}
			System.out.print(obj + " ");
//			result += (obj + " ");
		}
		shuffle = new Shuffle(cardsAll); // 二、洗牌
		washedCards = shuffle.getWashedCards(); // 三、获取一副洗好了的牌
		cplayers = new CreatPlayers(); // 四、创建玩家
		players0 = cplayers.getPlayers();
		// System.out.println(players0[1]); //检验是否建立好玩家
		dealer = new Dealer().getDealer(players0); // 五、从四名玩家中选出一名庄家
		System.out.println("\n\n" + "本局庄家是:" + dealer.getName() + " " + "\n\n");
		result = ("\n\n" + "本局庄家是:" + dealer.getName() + " " + "\n\n") + result;
		spoker = new SendPoker(); // 发牌
		players1 = spoker.sendPoker(players0, washedCards); // 牌发完
		Player player = new Player();
		for (int i = 0; i < players1.length; i++) {
			player.getBiggestCards(players1[i].getPocket());
			// System.out.println(players1[i].getOneOfPocket(3));
			// System.out.println(player.getBiggestCards(players1[i].getPocket()));
		}
		for (int i = 0; i < players1.length; i++) {
			Compare.pointOfBull(players1[i]);
			Compare.isBull(players1[i]);
			// System.out.println(players1[i].getPointOfBull());
		}
		view = new View(dealer);
		result += view.view(players1);
		return result;
	}

	
}
